package com.dnjn.happiness.biz.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dnjn.happiness.biz.domain.HistoryInterview;
import com.dnjn.happiness.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * 历史沟通记录Mapper接口
 *
 * @author happiness
 * @date 2023-11-20
 */
public interface HistoryInterviewMapper extends BaseMapper<HistoryInterview> {

    //    @Select("SELECT COUNT(*) AS count,curr_date FROM tory_interview WHERE DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= curr_date GROUP BY curr_date ORDER BY curr_date")
//    @Select("SELECT COUNT(*) AS count,curr_date FROM biz_history_interview WHERE curr_date BETWEEN #{startTime} AND #{endTime} GROUP BY curr_date ORDER BY curr_date")
    @Select("SELECT IFNULL(data.count, 0) AS count, day_list.day as currDate from " +
            "(SELECT COUNT( * ) AS count,curr_date AS day FROM biz_history_interview WHERE curr_date BETWEEN #{startTime}  AND  #{endTime}" +
            " GROUP BY curr_date ORDER BY curr_date) data right join " +
            "(SELECT @date := DATE_ADD(@date, interval 1 day) day from (SELECT @date := DATE_ADD(#{startTime}, interval -1 day) from biz_history_interview)" +
            " days limit 31) day_list on day_list.day = data.day")
    List<HistoryInterview> getHistoryInterviewEcharts(@Param("startTime") String startTime, @Param("endTime") String endTime);

    Page<HistoryInterview> getPage(@Param("page") Page page, @Param("dto") HistoryInterview historyInterview);


    Page<SysUser> getPageX(@Param("page") Page page, @Param("map") HashMap<String, Object> map);

}
